package com.courseware.online.controller;

import com.courseware.online.dto.UserDTO;
import com.courseware.online.service.MenuService;
import com.courseware.online.service.UserService;
import com.courseware.online.vo.MenuVO;
import com.courseware.online.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @author : demos
 */
@RestController
@RequestMapping(value = "api/user")
public class UserController {
    @Autowired
    private MenuService menuService;
    @Autowired
    private UserService userService;


    @PostMapping(value = "/login")
    @ResponseBody
    public ResultVO login(@RequestBody UserDTO user) {
        return new ResultVO(userService.login(user));
    }

    @PostMapping(value = "/update")
    @ResponseBody
    public ResultVO update(@RequestBody UserDTO user) {
        return new ResultVO(userService.update(user));
    }

    @PostMapping(value = "/register")
    @ResponseBody
    public ResultVO register(@RequestBody UserDTO user) {
        return new ResultVO(userService.Register(user));
    }

    @PostMapping(value = "/menu")
    @ResponseBody
    public ResultVO getMenu() {
        return new ResultVO(menuService.getAllMenu());
    }
}
